package net.bw.realtime.jtp.dws.log.function;

import net.bw.realtime.jtp.dws.log.bean.PageViewBean;
import org.apache.flink.api.common.functions.ReduceFunction;

/*
 * @author liuyawei
 * @date 2025/5/20
 */
public class PageViewReportReduceFunction implements ReduceFunction<PageViewBean> {

    @Override
    public PageViewBean reduce(PageViewBean temp, PageViewBean bean) throws Exception {

        // 1.增量计算
        temp.setPvCount(temp.getPvCount() + bean.getPvCount());
        temp.setPvDuringTime(temp.getPvDuringTime() + bean.getPvDuringTime());
        temp.setUvCount(temp.getUvCount() + bean.getUvCount());
        temp.setSessionCount(temp.getSessionCount() + bean.getSessionCount());

        // 2.返回结果
        return temp;
    }
}
